/**
 * All rights Reserved, Designed By OprCalf
 * Copyright:    Copyright(C) 2016-2020
 * Company       LengYin Ltd.
 */

package com.platform.gateway.common.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @projectName:  widget-web-request
 * @package:      com.widget.request.config
 * @className:    RestTemplateConfig.java
 * @description:  resttemplate配置
 * @author:       OprCalf
 * @date:         2019年1月29日
 */
@Configuration
public class RestTemplateConfig {

    @Bean(name = "balanceTemplate")
    @LoadBalanced
    public RestTemplate balanceTemplate() {
        final RestTemplate restTemplate = new RestTemplate(new OkHttp3ClientHttpRequestFactory());
        return restTemplate;
    }

    @Bean(name = "singleTemplate")
    public RestTemplate singleTemplate() {
        final RestTemplate restTemplate = new RestTemplate(new OkHttp3ClientHttpRequestFactory());
        return restTemplate;
    }

}
